<template>
  <div class="p-4">
    <div class="bg-white mb-2" style="">
      <slot></slot>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { computed, onMounted, ref } from 'vue';
import { propTypes } from '/@/utils/propTypes';
import { isFunction } from '/@/common/util/is';
// 获取slider属性

//暴露内部方法
const emit = defineEmits(['getMethod', 'delete']);
//数据
const data = ref([]);
const grid = ref(4);
// 切换每行个数
// cover图片自适应高度
//修改pageSize并重新请求数据

const height = computed(() => {
  return `h-${120 - grid.value * 6}`;
});

// 组件接收参数
const props = defineProps({
  // 请求API的参数
  params: propTypes.object.def({}),
  //api
  api: propTypes.func,
  data: propTypes.array,
});

// 自动请求并暴露内部方法
onMounted(() => {
  fetch();
  emit('getMethod', fetch);
});

//表单提交
async function handleSubmit() {
}

async function fetch(p = {}) {
  const { api, params } = props;
  if (api && isFunction(api)) {
    const res = await api({ ...params });
    data.value = res.records;
  }
}

async function handleDelete(id) {
  emit('delete', id);
}
</script>